﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Shmup_Project
{
    public class Projectile: WorldObject
    {
        
        public int damage = 5;
        public int Width
        { get { return boundingBox.Width; } }
        public int Height
        {get {return boundingBox.Height;}}
        const int PROJECTILEHEIGHT = 5;
        const int PROJECTILEWIDTH = 10;
        public double  projectileLife;
        Vector2 movementVector;
        double totalLifeTime =0;


        protected float projectileMoveSpeed = 2000f;

        public Projectile(Game1 gameClass, int xPosition, int yPosition, Vector2 movementVector)
            : base(gameClass, xPosition, yPosition, PROJECTILEHEIGHT, PROJECTILEWIDTH)
        {
            movementVector.Normalize();
            this.movementVector = movementVector;
            bCleanUp = false;
            damage = 20;
            projectileLife = .5f;
            LoadContent();
            objectType = ObjectType.PlayerProjectile;
        }

        public override void LoadContent()
        {
            texture = gameClass.Content.Load<Texture2D>("laser");
            base.LoadContent();
        }
        

        public override void Update(GameTime gameTime)
        {
            position.Y += ((float)gameTime.ElapsedGameTime.TotalSeconds * projectileMoveSpeed) * -movementVector.Y;
            position.X += ((float)gameTime.ElapsedGameTime.TotalSeconds * projectileMoveSpeed) * movementVector.X;
            totalLifeTime += (gameTime.ElapsedGameTime.TotalSeconds);
            if (totalLifeTime >= projectileLife)
            {
                bCleanUp = true;
            }
                base.Update(gameTime);
           
        }


    }
}
